package view;

import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;

public class GoWindow extends JFrame{

	private JTextField textField;
	private ActionListener listener;

	/**
	 * Create the application.
	 */
	public GoWindow() {
		new GoWindow(null);
		
	}
	
	public GoWindow(ActionListener listener)
	{
		
		System.setProperty("apple.laf.useScreenMenuBar", "true");
		setBounds(50, 50, 200, 200);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setResizable(false);
		
		JMenuBar menuBar = new JMenuBar();

		JMenu mnFile = new JMenu("Switch");
		menuBar.add(mnFile);
		
		JMenuItem simpleMode = new JMenuItem("Workspace Mode");
		simpleMode.setActionCommand("Switch to Workspace");
		simpleMode.addActionListener((ActionListener) listener);
		simpleMode.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
		mnFile.add(simpleMode);
		this.setJMenuBar(menuBar);

		
		JButton btnNewButton = new JButton("Go");
		Font f = new Font("Dialog", Font.PLAIN, 24);
		getContentPane().setLayout(new MigLayout("insets 1", "[200px][]", "[150px][28px]"));
		btnNewButton.setFont(f);
		btnNewButton.addActionListener(listener);
		btnNewButton.setActionCommand("Simple Go");

		getContentPane().add(btnNewButton, "cell 0 0 2 1,grow");
		
		textField = new JTextField();
		getContentPane().add(textField, "cell 0 1,growx,aligny top");
		textField.setColumns(10);
		
//		JButton btnNewButton_1 = new JButton("Workspace");
//		btnNewButton_1.setActionCommand("Switch to Workspace");
//		btnNewButton_1.addActionListener(listener);
//		getContentPane().add(btnNewButton_1, "cell 1 1");
		//setVisible(true);
	}
	
	public String getText()
	{
		return textField.getText();
	}
	
	public void clearText()
	{
		textField.setText("");
	}
}
